package lesson_type

import "fmt"

type Person struct {
	Name string `json:"name"`
	Age  int    `json:"age"`
	sex  string `json:"sex"`
}

func NewPerson(name string, age int) *Person {
	return &Person{
		Name: name,
		Age:  age,
	}
}

func (p *Person) Introduce() string {
	return fmt.Sprintf("我的名字叫%s,今年%d岁", p.Name, p.Age)
}

func (p *Person) SetSet(sex string) {
	p.sex = sex
}

func (p *Person) GetSex() string {
	return p.sex
}

type Teacher struct {
	Person
	Telephone string `json:"telephone"`
	Address   string `json:"address"`
}

/*
修改 Person 结构体，使其嵌入 Teacher 结构体而不是直接包含其字段。
*/

func NewTeacher(name string, age int, telephone string, address string) *Teacher {
	return &Teacher{
		Person:    *NewPerson(name, age),
		Telephone: telephone,
		Address:   address,
	}
}

func (t *Teacher) Introduce() string {
	return fmt.Sprintf("我的名字叫%s,今年%d岁,我的电话是%s,我的地址是%s", t.Name, t.Age, t.Telephone, t.Address)
}
